package com.buba.controller;

import com.buba.po.User;
import com.buba.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/findUserById/{id}")
    public User findUserById(@PathVariable("id") Integer id){
        User user =  userService.findUserById(id);
        System.out.println("9999");
        user.setUsername("99999"+user.getUsername());
        return user;
    }
    //http://127.0.0.1:7001/user/findUserById2?id=2
    @GetMapping("/findUserById2")
    public User findUserById2(@RequestParam Integer id){
        User user =  userService.findUserById(id);
        System.out.println("9999");
        user.setUsername("99999"+user.getUsername());
        return user;
    }


    @PostMapping("/findByUser")
    public User findByUser(@RequestBody User user){
        return  userService.findUserById(user.getUid());
    }
}
